package se480.paf.filters.impl;

import se480.paf.filters.ActiveFilter;
import se480.paf.pipes.Item;
import se480.paf.pipes.Pipe;
import se480.paf.pipes.impl.Queue;


public class TestFilter2 implements ActiveFilter {
	
	String name = "F2";
	int msSleep = 2000; // Default Thread sleep time
	
	public Pipe<Item> inPipe;
	public Pipe<Item> outPipe;


	
	@Override
	public void run() {
		try {
		      int i = 0;
		      while (true) {
		    	 if (!inPipe.isEmpty()) {
		    		 Item item = inPipe.removeItem();
		    		 String s = (String)item.getItem();
		    		 System.out.println(name + " picked up " + s);
		    	 }
		    	  
		         System.out.println(name + " wake: " + i++);
		         Thread.sleep(msSleep);

		      }
      } catch (InterruptedException e) {
         System.out.println(name + " interrupted.");
      }
		      System.out.println(name + " exiting.");

	}

	@Override
	public void process(Item item) {
		// TODO Auto-generated method stub

	}


	@Override
	public void setInPipe(Pipe<Item> pipe) {
		this.inPipe = pipe;
	}

	@Override
	public void setOutPipe(Pipe<Item> pipe) {
		this.outPipe = pipe;
	}


	@Override
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public void setSleep(int msSleep) {
		this.msSleep = msSleep;
	}

	@Override
	public int getSleep() {
		return this.msSleep;
	}

	@Override
	public Pipe<Item> getInPipe() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Pipe<Item> getOutPipe() {
		// TODO Auto-generated method stub
		return null;
	}

}
